home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_enscript.idb / usr / freeware / catman / u_man / cat1 / states.Z / states
Encoding:
Text File  |  1998-10-28  |  16.9 KB  |  397 lines

  1.  
  2.  
  3.  
  4.      SSSSTTTTAAAATTTTEEEESSSS((((1111))))           SSSSTTTTAAAATTTTEEEESSSS ((((JJJJuuuunnnn 6666,,,, 1111999999997777))))             SSSSTTTTAAAATTTTEEEESSSS((((1111))))
  5.  
  6.  
  7.  
  8.      NNNNAAAAMMMMEEEE
  9.       states - awk alike text processing tool
  10.  
  11.  
  12.      SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  13.       ssssttttaaaatttteeeessss [----hhhhVVVV] [----DDDD _v_a_r====_v_a_l] [----ffff    _f_i_l_e] [----oooo _o_u_t_p_u_t_f_i_l_e] [----ssss
  14.       _s_t_a_r_t_s_t_a_t_e] [----WWWW _l_e_v_e_l] [_f_i_l_e_n_a_m_e ...]
  15.  
  16.  
  17.      DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  18.       SSSSttttaaaatttteeeessss is an awk-alike text processing tool with some    state
  19.       machine extensions.  It is designed for program source code
  20.       highlighting and to similar tasks where state    information
  21.       helps    input processing.
  22.  
  23.       At a single point of time, SSSSttttaaaatttteeeessss is in one state, each
  24.       quite    similar    to awk's work environment, they    have regular
  25.       expressions which are    matched    from the input and actions
  26.       which    are executed when a match is found.  From the action
  27.       blocks, ssssttttaaaatttteeeessss can perform state transitions;    it can move to
  28.       another state    from which the processing is continued.     State
  29.       transitions are recorded so ssssttttaaaatttteeeessss can return    to the calling
  30.       state    once the current state has finished.
  31.  
  32.       The biggest difference between ssssttttaaaatttteeeessss    and awk, besides state
  33.       machine extensions, is that ssssttttaaaatttteeeessss is    not line-oriented.  It
  34.       matches regular expression tokens from the input and once a
  35.       match    is processed, it continues processing from the current
  36.       position, not    from the beginning of the next input line.
  37.  
  38.  
  39.      OOOOPPPPTTTTIIIIOOOONNNNSSSS
  40.       ----DDDD _v_a_r====_v_a_l,,,, --------ddddeeeeffffiiiinnnneeee====_v_a_r====_v_a_l
  41.           Define variable _v_a_r to have string value _v_a_l.
  42.           Command line definitions overwrite variable
  43.           definitions found from the config file.
  44.  
  45.       ----ffff _f_i_l_e,,,, --------ffffiiiilllleeee====_f_i_l_e
  46.           Read state definitions from file _f_i_l_e.  As a
  47.           default, ssssttttaaaatttteeeessss tries    to read    state definitions from
  48.           file ssssttttaaaatttteeeessss....sssstttt in the    current    working    directory.
  49.  
  50.       ----hhhh,,,, --------hhhheeeellllpppp
  51.           Print    short help message and exit.
  52.  
  53.       ----oooo _f_i_l_e,,,, --------oooouuuuttttppppuuuutttt====_f_i_l_e
  54.           Save output to file _f_i_l_e instead of printing it to
  55.           ssssttttddddoooouuuutttt.
  56.  
  57.       ----ssss _s_t_a_t_e,,,, --------ssssttttaaaatttteeee====_s_t_a_t_e
  58.           Start    execution from state ssssttttaaaatttteeee.  This definition
  59.           overwrites start state resolved from the ssssttttaaaarrrrtttt
  60.  
  61.  
  62.  
  63.      Page 1                         (printed 7/30/98)
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.      SSSSTTTTAAAATTTTEEEESSSS((((1111))))           SSSSTTTTAAAATTTTEEEESSSS ((((JJJJuuuunnnn 6666,,,, 1111999999997777))))             SSSSTTTTAAAATTTTEEEESSSS((((1111))))
  71.  
  72.  
  73.  
  74.           block.
  75.  
  76.       ----VVVV,,,, --------vvvveeeerrrrssssiiiioooonnnn
  77.           Print    ssssttttaaaatttteeeessss version and exit.
  78.  
  79.       ----WWWW _l_e_v_e_l,,,, --------wwwwaaaarrrrnnnniiiinnnngggg====_l_e_v_e_l
  80.           Set the warning level    to _l_e_v_e_l.  Possible values for
  81.           _l_e_v_e_l    are:
  82.  
  83.           lllliiiigggghhhhtttt      light    warnings (default)
  84.  
  85.           aaaallllllll      all warnings
  86.  
  87.  
  88.      SSSSTTTTAAAATTTTEEEESSSS PPPPRRRROOOOGGGGRRRRAAAAMMMM FFFFIIIILLLLEEEESSSS
  89.       SSSSttttaaaatttteeeessss program files can contain on _s_t_a_r_t block, _s_t_a_r_t_r_u_l_e_s
  90.       and _n_a_m_e_r_u_l_e_s    blocks to specify the initial state, _s_t_a_t_e
  91.       definitions and _e_x_p_r_e_s_s_i_o_n_s.
  92.  
  93.       The _s_t_a_r_t block is the main()    of the ssssttttaaaatttteeeessss program, it is
  94.       executed on script startup for each input file and it    can
  95.       perform any initialization the script    needs.    It normally
  96.       also calls the cccchhhheeeecccckkkk____ssssttttaaaarrrrttttrrrruuuulllleeeessss(((()))) and    cccchhhheeeecccckkkk____nnnnaaaammmmeeeerrrruuuulllleeeessss(((())))
  97.       primitives which resolve the initial state from the input
  98.       file name or the data    found from the begining    of the input
  99.       file.     Here is a sample start    block which initializes    two
  100.       variables and    does the standard start    state resolving:
  101.  
  102.            start
  103.            {
  104.          a = 1;
  105.          msg = "Hello, world!";
  106.          check_startrules ();
  107.          check_namerules ();
  108.            }
  109.  
  110.       Once the start block is processed, the input processing is
  111.       continued from the initial state.
  112.  
  113.       The initial state is resolved    by the information found from
  114.       the _s_t_a_r_t_r_u_l_e_s and _n_a_m_e_r_u_l_e_s blocks.    Both blocks contain
  115.       regular expression - symbol pairs, when the regular
  116.       expression is    matched    from the name of from the beginning of
  117.       the input file, the initial state is named by    the
  118.       corresponding    symbol.     For example, the following start and
  119.       name rules can distinguish C and Fortran files:
  120.  
  121.            namerules
  122.            {
  123.          /.(c|h)$/    c;
  124.          /.[fF]$/     fortran;
  125.            }
  126.  
  127.  
  128.  
  129.      Page 2                         (printed 7/30/98)
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.      SSSSTTTTAAAATTTTEEEESSSS((((1111))))           SSSSTTTTAAAATTTTEEEESSSS ((((JJJJuuuunnnn 6666,,,, 1111999999997777))))             SSSSTTTTAAAATTTTEEEESSSS((((1111))))
  137.  
  138.  
  139.  
  140.            startrules
  141.            {
  142.          /- [cC] -/     c;
  143.          /- fortran -/     fortran;
  144.            }
  145.  
  146.       If these rules are used with the previously shown start
  147.       block, ssssttttaaaatttteeeessss    first check the    beginning of input file.  If
  148.       it has string    ----****---- cccc ----****----, the file is assumed to contain C
  149.       code and the processing is started from state    called cccc.  If
  150.       the beginning    of the input file has string ----****---- ffffoooorrrrttttrrrraaaannnn ----****----,
  151.       the initial state is ffffoooorrrrttttrrrraaaannnn.     If none of the    start rules
  152.       matched, the name of the input file is matched with the
  153.       namerules.  If the name ends to suffix cccc or CCCC, we go to
  154.       state    cccc.  If the suffix is ffff or FFFF, the initial state is
  155.       fortran.
  156.  
  157.       If both start    and name rules failed to resolve the start
  158.       state, ssssttttaaaatttteeeessss    just copies its    input to output    unmodified.
  159.  
  160.       The start state can also be specified    from the command line
  161.       with option ----ssss, --------ssssttttaaaatttteeee.
  162.  
  163.       State    definitions have the following syntax:
  164.  
  165.       ssssttttaaaatttteeee    {{{{ _e_x_p_r {_s_t_a_t_e_m_e_n_t_s} ...    }
  166.  
  167.       where    _e_x_p_r is: a regular expression, special expression or
  168.       symbol and _s_t_a_t_e_m_e_n_t_s    is a list of statements.  When the
  169.       expression _e_x_p_r is matched from the input, the statement
  170.       block    is executed.  The statement block can call ssssttttaaaatttteeeessss'
  171.       primitives, user-defined subroutines,    call other states,
  172.       etc.    Once the block is executed, the    input processing is
  173.       continued from the current intput position (which might have
  174.       been changed if the statement    block called other states).
  175.  
  176.       Special expressions BBBBEEEEGGGGIIIINNNN and    EEEENNNNDDDD can    be used    in the place
  177.       of _e_x_p_r.  Expression BBBBEEEEGGGGIIIINNNN matches the beginning of the
  178.       state, its block is called when the state is entered.
  179.       Expression EEEENNNNDDDD matches the end of the    state, its block is
  180.       executed when    ssssttttaaaatttteeeessss leaves the state.
  181.  
  182.       If _e_x_p_r is a symbol, its value is looked up from the global
  183.       environment and if it    is a regular expression, it is matched
  184.       to the input,    otherwise that rule is ignored.
  185.  
  186.       The ssssttttaaaatttteeeessss program file can also have    top-level expressions,
  187.       they are evaluated after the program file is parsed but
  188.       before any input files are processed or the _s_t_a_r_t block is
  189.       evaluated.
  190.  
  191.  
  192.  
  193.  
  194.  
  195.      Page 3                         (printed 7/30/98)
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.      SSSSTTTTAAAATTTTEEEESSSS((((1111))))           SSSSTTTTAAAATTTTEEEESSSS ((((JJJJuuuunnnn 6666,,,, 1111999999997777))))             SSSSTTTTAAAATTTTEEEESSSS((((1111))))
  203.  
  204.  
  205.  
  206.      PPPPRRRRIIIIMMMMIIIITTTTIIIIVVVVEEEE FFFFUUUUNNNNCCCCTTTTIIIIOOOONNNNSSSS
  207.       ccccaaaallllllll ((((_s_y_m_b_o_l))))
  208.           Move to state    _s_y_m_b_o_l and continue input file
  209.           processing from that state.  Function    returns
  210.           whatever the ssssyyyymmmmbbbboooollll state's terminating rrrreeeettttuuuurrrrnnnn
  211.           statement returned.
  212.  
  213.       cccchhhheeeecccckkkk____nnnnaaaammmmeeeerrrruuuulllleeeessss (((())))
  214.           Try to resolve start state from nnnnaaaammmmeeeerrrruuuulllleeeessss rules.
  215.           Function returns 1111 if    start state was    resolved or 0000
  216.           otherwise.
  217.  
  218.       cccchhhheeeecccckkkk____ssssttttaaaarrrrttttrrrruuuulllleeeessss (((())))
  219.           Try to resolve start state from ssssttttaaaarrrrttttrrrruuuulllleeeessss rules.
  220.           Function returns 1111 if    start state was    resolved or 0000
  221.           otherwise.
  222.  
  223.       ccccoooonnnnccccaaaatttt ((((_s_t_r,,,, ............))))
  224.           Concanate argument strings and return    result as a
  225.           new string.
  226.  
  227.       ffffllllooooaaaatttt    ((((_a_n_y))))
  228.           Convert argument to a    floating point number.
  229.  
  230.       ggggeeeetttteeeennnnvvvv ((((_s_t_r))))
  231.           Get value of environment variable _s_t_r.  Returns an
  232.           empty    string if variable _v_a_r is undefined.
  233.  
  234.       iiiinnnntttt ((((_a_n_y))))
  235.           Convert argument to an integer number.
  236.  
  237.       lllleeeennnnggggtttthhhh ((((_i_t_e_m,,,,    ............))))
  238.           Count    the length of argument strings or lists.
  239.  
  240.       lllliiiisssstttt ((((_a_n_y,,,, ............))))
  241.           Create a new list which contains items _a_n_y, ...
  242.  
  243.       ppppaaaannnniiiicccc    ((((_a_n_y,,,, ............))))
  244.           Report a non-recoverable error and exit with status
  245.           1111.  Function never returns.
  246.  
  247.       pppprrrriiiinnnntttt    ((((_a_n_y,,,, ............))))
  248.           Convert arguments to strings and print them to the
  249.           output.
  250.  
  251.       rrrraaaannnnggggeeee    ((((_s_o_u_r_c_e,,,, _s_t_a_r_t,,,,    _e_n_d))))
  252.           Return a sub-range of    _s_o_u_r_c_e starting    from position
  253.           _s_t_a_r_t    (inclusively) to _e_n_d (exclusively).  Argument
  254.           _s_o_u_r_c_e can be    string or list.
  255.  
  256.       rrrreeeeggggeeeexxxxpppp ((((_s_t_r_i_n_g))))
  257.           Convert string _s_t_r_i_n_g    to a new regular expression.
  258.  
  259.  
  260.  
  261.      Page 4                         (printed 7/30/98)
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.      SSSSTTTTAAAATTTTEEEESSSS((((1111))))           SSSSTTTTAAAATTTTEEEESSSS ((((JJJJuuuunnnn 6666,,,, 1111999999997777))))             SSSSTTTTAAAATTTTEEEESSSS((((1111))))
  269.  
  270.  
  271.  
  272.       rrrreeeeggggeeeexxxxpppp____ssssyyyynnnnttttaaaaxxxx    ((((_c_h_a_r,,,, _s_y_n_t_a_x))))
  273.           Modify regular expression character syntaxes by
  274.           assigning new    syntax _s_y_n_t_a_x for character _c_h_a_r.
  275.           Possible values for _s_y_n_t_a_x are:
  276.  
  277.           ''''wwww''''      character is a word constituent
  278.  
  279.           '''' ''''      character isn't a word constituent
  280.  
  281.       rrrreeeeggggmmmmaaaattttcccchhhh ((((_s_t_r_i_n_g,,,, _r_e_g_e_x_p))))
  282.           Check    if string _s_t_r_i_n_g matches regular expression
  283.           _r_e_g_e_x_p.  Functions returns a boolean success status
  284.           and sets sub-expression registers $$$$_n.
  285.  
  286.       rrrreeeeggggssssuuuubbbb ((((_s_t_r_i_n_g, _r_e_g_e_x_p,,,, _s_u_b_s_t))))
  287.           Search regular expression _r_e_g_e_x_p from    string _s_t_r_i_n_g
  288.           and replace the matching substring with string
  289.           _s_u_b_s_t.  Returns the resulting    string.     The
  290.           substitution string _s_u_b_s_t can    contain    $$$$_n references
  291.           to the _n:th parenthesized sup-expression.
  292.  
  293.       rrrreeeeggggssssuuuubbbbaaaallllllll ((((_s_t_r_i_n_g, _r_e_g_e_x_p,,,, _s_u_b_s_t))))
  294.           Like rrrreeeeggggssssuuuubbbb but replace all matches of regular
  295.           expression _r_e_g_e_x_p from string    _s_t_r_i_n_g with string
  296.           _s_u_b_s_t.
  297.  
  298.       sssspppplllliiiitttt    ((((_r_e_g_e_x_p,,,, _s_t_r_i_n_g))))
  299.           Split    string _s_t_r_i_n_g to list considering matches of
  300.           regular rexpression _r_e_g_e_x_p as    item separator.
  301.  
  302.       sssspppprrrriiiinnnnttttffff ((((_f_m_t,    ...)
  303.           Format arguments according to    _f_m_t and    return result
  304.           as a string.
  305.  
  306.       ssssttttrrrrccccmmmmpppp ((((_s_t_r_1,,,,    _s_t_r_2))))
  307.           Perform a case-sensitive comparision for strings
  308.           _s_t_r_1 and _s_t_r_2.  Function returns a value that    is:
  309.  
  310.           ----1111      string _s_t_r_1 is less than _s_t_r_2
  311.  
  312.           0000      strings are equal
  313.  
  314.           1111      string _s_t_r_1 is greater than _s_t_r_2
  315.  
  316.       ssssttttrrrriiiinnnngggg ((((_a_n_y))))
  317.           Convert argument to string.
  318.  
  319.       ssssttttrrrrnnnnccccmmmmpppp ((((_s_t_r_1,,,, _s_t_r_2,,,, _n_u_m))))
  320.           Perform a case-sensitive comparision for strings
  321.           _s_t_r_1 and _s_t_r_2    comparing at maximum _n_u_m cccchhhhaaaarrrraaaacccctttteeeerrrrssss....
  322.  
  323.       ssssuuuubbbbssssttttrrrriiiinnnngggg ((((_s_t_r,,,, _s_t_a_r_t,,,, _e_n_d))))
  324.  
  325.  
  326.  
  327.      Page 5                         (printed 7/30/98)
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.      SSSSTTTTAAAATTTTEEEESSSS((((1111))))           SSSSTTTTAAAATTTTEEEESSSS ((((JJJJuuuunnnn 6666,,,, 1111999999997777))))             SSSSTTTTAAAATTTTEEEESSSS((((1111))))
  335.  
  336.  
  337.  
  338.           Return a substring of    string _s_t_r starting from
  339.           position _s_t_a_r_t (inclusively) to _e_n_d (exclusively).
  340.  
  341.  
  342.      BBBBUUUUIIIILLLLTTTTIIIINNNN VVVVAAAARRRRIIIIAAAABBBBLLLLEEEESSSS
  343.       $$$$....      current input    line number
  344.  
  345.       $$$$_n      the _nth parenthesized    regular    expression sub-
  346.           expression from the latest state regular expression
  347.           or from the rrrreeeeggggmmmmaaaattttcccchhhh primitive
  348.  
  349.       $$$$````      everything before the    matched    regular    rexpression.
  350.           This is usable when used with    the rrrreeeeggggmmmmaaaattttcccchhhh
  351.           primitive; the contents of this variable is
  352.           undefined when used in action    blocks to refer    the
  353.           data before the block's regular expression.
  354.  
  355.       $$$$BBBB      an alias for $$$$````
  356.  
  357.       aaaarrrrggggvvvv      list of input    file names
  358.  
  359.       ffffiiiilllleeeennnnaaaammmmeeee
  360.           name of the current input file
  361.  
  362.       pppprrrrooooggggrrrraaaammmm name of the program (usually ssssttttaaaatttteeeessss)
  363.  
  364.       vvvveeeerrrrssssiiiioooonnnn program version string
  365.  
  366.  
  367.      FFFFIIIILLLLEEEESSSS
  368.       /usr/freeware/share/enscript/enscript.stenscript's states definitions
  369.  
  370.  
  371.      SSSSEEEEEEEE AAAALLLLSSSSOOOO
  372.       awk(1), enscript(1)
  373.  
  374.  
  375.      AAAAUUUUTTTTHHHHOOOORRRR
  376.       Markku Rossi <mtr@iki.fi> <http://www.iki.fi/~mtr/>
  377.  
  378.       GNU Enscript WWW home    page:
  379.       <http://www.iki.fi/~mtr/genscript/>
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.      Page 6                         (printed 7/30/98)
  394.  
  395.  
  396.  
  397.